@include('admin.public.head')
@include('admin.public.pop')
@include('admin.public.laydate')
<link href="{{ URL::asset('./admin/css/class_base.css') }}" rel="stylesheet">

<div class="ibox-title" style="border: 0px">
    <h5>老师添加 &nbsp;&nbsp;</h5></br></br>
</div>

<div class="ibox-content">
    <form  class="form-horizontal">

        <div class="form-group">
            <label class="col-sm-3 control-label">指定上课时间：</label>
            <div class="col-sm-3">
                <textarea class="layui-textarea laydate-test-area" name="designated_date" rows="5" readonly></textarea>
            </div>
        </div>
        <div class="hr-line-dashed"></div>

        <div class="form-group">
            <label class="col-sm-3 control-label">上课老师：</label>
            <div class="col-sm-3">
                <select class="form-control" name="teacher_id">
                    @foreach($class_bass_info_teacher as $k=>$v)
                        <option value="{{$v->id}}" >{{$v->teacher_name}}</option>
                    @endforeach
                </select>
            </div>
        </div>
        <div class="hr-line-dashed"></div>

        <div class="form-group">
            <label class="col-sm-3 control-label">是否公共：</label>
            <div class="col-sm-9">
                <label value="1">
                    <input type="radio" name="is_common"  value="1" >是
                </label>
                <label value="0">
                    <input type="radio" name="is_common"  value="-1"  checked="checked">否
                </label>
            </div>
        </div>

        <div class="form-group">
            <div class="col-sm-4 col-sm-offset-3">
                <input type="hidden" name="class_base_info_id" value="{{$id??0}}">
                <a href="javascript:void(0)" class="btn btn-primary do" type="submit">操作</a>
                <a href="/class_base_info_teacher/{{$id}}" class="btn btn-primary" type="submit">返回</a>
            </div>
        </div>
    </form>
</div>

<script>

    $('.do').click(function(){
        var form = new FormData();

        var designated_date = $('textarea[name="designated_date"]').val();
        var teacher_id = $('select[name="teacher_id"] option:selected').val();
        var class_base_info_id = $('input[name="class_base_info_id"]').val();
        var is_common = $('input[name="is_common"]:checked').val();

        form.append("designated_date", designated_date);
        form.append("teacher_id", teacher_id);
        form.append("class_base_info_id", class_base_info_id);
        form.append("is_common", is_common);

        $.ajax({
            type: 'POST',
            url: '/class_base_info_teacher_do' ,
            dataType:"json",   //返回格式为json
            data: form ,
            processData: false,
            contentType: false,
            success:function(data){

                if(data.status == '1') {
                    var swal_json = {
                        title: data.message,
                        type: "success"
                    }

                    swal(swal_json, function (isConfirm) {
                        window.location.reload();
                    });

                }else{
                    var swal_json = {
                        title: data.message,
                        type: "error"
                    }

                    swal(swal_json, function (isConfirm) {

                    });
                }
            }
        });

        return false;
    });

</script>



